﻿@{
    var logList = ViewBag.logList as List<ViewLogSql>;
}
<style>
    .countAll { padding: 10px 30px 10px 30px; text-align: center; }
        .countAll i { font-size: 35px; color: #1E9FFF; }
        .countAll .num { font-size: 30px; color: #1E9FFF; line-height: 42px; height: 42px; }
        .countAll .tip { font-size: 14px; color: #333; line-height: 25px; height: 25px; }
</style>
<div class="content-top-nav">
    <h3 style="color:#444"><i class="layui-icon layui-icon-home"> 控制台</i>  </h3>
    <hr>
</div>

<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-col-md12 layui-col-space15" style="height:283px;">
            <div class="layui-col-md3">
                <fieldset class="layui-elem-field">
                    <legend>
                        <i class="layui-icon layui-icon-chart" style="font-size:18px;">
                            我的动态
                        </i>
                    </legend>
                    <div class="layui-field-box">
                        <ul class="layui-timeline">
                            @foreach (var item in logList)
                            {
                                <li class="layui-timeline-item">
                                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                                    <div class="layui-timeline-content layui-text">
                                        <h4 class="layui-timeline-title">@item.Time</h4>
                                        <ul>
                                            <li>@item.Name <span>@item.Ip</span></li>
                                        </ul>
                                    </div>
                                </li>
                            }
                        </ul>
                    </div>
                </fieldset>
            </div>
            <div class="layui-col-md5">
                <fieldset class="layui-elem-field">
                    <legend>
                        <i class="layui-icon layui-icon-list" style="font-size:18px;">
                            系统统计
                        </i>
                    </legend>
                    <div class="layui-field-box layui-col-space15" style="height:283px;">
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-form"></i><div class="num" id="countArticle"></div><div class="tip">报送数据总量</div></div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-read"></i><div class="num" id="countDocreceived"></div><div class="tip">来文登记数</div></div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-tabs"></i><div class="num" id="countStatement"></div><div class="tip">报表总量</div></div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-user"></i><div class="num" id="countUser"></div><div class="tip">系统用户数</div></div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-log"></i><div class="num" id="countLog"></div><div class="tip">日志总数</div></div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-panel">
                                <div class="countAll layui-anim layui-anim-scaleSpring"><i class="layui-icon layui-icon-dialogue"></i><div class="num" id="countNotice"></div><div class="tip">消息总数</div></div>
                            </div>
                        </div>
                    </div>
                </fieldset>
            </div>
            <div class="layui-col-md4">
                <fieldset class="layui-elem-field">
                    <legend>
                        <i class="layui-icon layui-icon-email" style="font-size:18px;cursor:pointer;" lay-header-event="menuRight" lay-unselect>
                            我的消息
                            <span class="layui-badge" id="count-notice-home">0</span>
                        </i>
                    </legend>
                    <div class="layui-field-box" style="height:268px;">
                        <ul id="noticeList" style="line-height:35px;color:green;">
                        </ul>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <!--统计图表展示 S-->

        <div class="layui-col-md12">
            <div id="forUserMonth" style="width:100%;height:500px;"></div>
        </div>

        <!--统计图表展示 E-->
    </div>
    <div class="layui-col-md12">
        <blockquote class="layui-elem-quote">

            本系统可应用于机关事业单位内部文件管理、绩效管理、文件流转、信息交流、部门官网等场景。<br />
            本系统基于 .NET6 + MYSQL 开发，可架设于互联网、内网及各类专网或单机使用，具有跨平台（Windows、Linux、MacOS等），兼容性、效率高、占用资源小等特点。<br />

        </blockquote>

        <br /><br /><br /><br />
    </div>
</div>
<script src="~/lib/chart/echarts.min.js"></script>
<script>
    layui.define(function () {
        var element = layui.element, layer = layui.layer, $ = layui.jquery, util = layui.util;

        util.event('lay-header-event', {
            menuRight: function () {
                layer.open({
                    type: 2
                    , title: '通知'
                    , content: "/Admin/Notice/Index?viewpost=2"
                    , area: ['260px', '100%']
                    , offset: 'rt' //右上角
                    , anim: 5
                    , shadeClose: true
                    , scrollbar: false
                    , move: false
                });
            }
        });

    });
    //消息开始
    function getNotice() {
        $('#noticeList').html("");
        $.getJSON("/Admin/Notice/Index?json=1&limit=8&status=-1", function (res) {
            if (res.data.length == 0) {
                $('#noticeList').append('<div class="layui-card" ><div class="layui-card-header" style="overflow:hidden;"><h4>没有信息，快叫好友给你发一条吧！</h4></div></div>');
            } else {
                $.each(res.data, function (index, value) {
                    if (value.status == 0) {
                        $('#noticeList').append('<li style="overflow:hidden;">  <div class="layui-col-md8"><span class="layui-badge-dot"></span> <a href="javascript:read(' + value.id + ',' + value.noticeId + ');">'
                            + Substr(value.title, 0, 40) + ' </a></div> <div class="layui-col-md4" style="text-align:right;">' + value.postTime + '</div> </li>');
                    } else {
                        $('#noticeList').append('<li style="overflow:hidden;">  <div class="layui-col-md8"><span class="layui-badge-dot layui-bg-green"></span> <a href="javascript:read(' + value.id + ',' + value.noticeId + ');">'
                            + Substr(value.title, 0, 40) + ' </a> </div> <div class="layui-col-md4" style="text-align:right;">' + value.postTime + '</div> </li>');
                    }
                });
            }
        });
    }

    getNotice();
    //消息结束


    function read(id, noticeId) {
        parent.layer.open({
            type: 2,
            title: "信息详情",
            area: ['800px', '500px'],
            closeBtn: 1, //不显示关闭按钮
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            content: "/Admin/Notice/Read?id=" + id + "&noticeid=" + noticeId
        });
    }
    //加载main.js 里的统计函数
    refExamineCount();
    refNoticeCount();

    $.getJSON("/Admin/Home/Home?view=1", function (res) {

        $("#countArticle").html(res.countAll.article);
        $("#countUser").html(res.countAll.user);
        $("#countDocreceived").html(res.countAll.docreceived);
        $("#countStatement").html(res.countAll.statement);
        $("#countLog").html(res.countAll.log);
        $("#countNotice").html(res.countAll.notice);

        var forUserMonth = echarts.init(document.getElementById('forUserMonth'), null, {
            //width: "100%",
          //  height: 400
        });
        var nameMonth = [];
        var valueMonth = [];
        var markNum = [];
        $.each(res.forUserMonth, function (i, arr) {
            nameMonth.push(arr["name"]);
            valueMonth.push(arr["value"]);
            markNum.push(arr["markNum"]);
        });

        forUserMonth.setOption({
            title: [
                {
                    text: '本月个人信息报送排名'
                }
            ],

            tooltip: {
                trigger: 'axis'
            },
            legend: {},
            toolbox: {
                show: true,
                feature: {
                    dataZoom: {
                        yAxisIndex: 'none'
                    },
                    //dataView: { readOnly: false },
                    magicType: { type: ['line', 'bar'] },
                    restore: {},
                    saveAsImage: {}
                }
            },
            xAxis: {
                grid: { y2: 140},
                type: 'category',
                //boundaryGap: false,
                data: nameMonth,
                axisLabel: {
                    interval: 0,
                    rotate: -30,
                    margin: 15
                }
            },
            yAxis: {
                type: 'value',
                axisLabel: {
                    formatter: '{value} 条'
                }
            },

            series: [
                {
                    name: '报送量',
                    type: 'bar',
                    data: valueMonth,
                    markPoint: {
                        data: [
                            { type: 'max', name: 'Max' },
                            { type: 'min', name: 'Min' }
                        ]
                    },
                    markLine: {
                        data: [{ type: 'average', name: 'Avg' }]
                    }
                },
                {
                    name: '采用量',
                    type: 'bar',
                    data: markNum,
                    markPoint: {
                        data: [
                            { type: 'max', name: 'Max' },
                            { type: 'min', name: 'Min' }
                        ]
                    },
                    markLine: {
                        data: [{ type: 'average', name: 'Avg' }]
                    }
                }
            ]
        });


    });
</script>